package com.yyt.threadpooldemo.schedule;

import com.yyt.threadpooldemo.service.AsyncService;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @author yeyangtao
 * @date 2020/6/8 16:07
 */
@Component
@EnableScheduling
public class MyScheduled {
    @Resource
    private AsyncService asyncService;

    @Scheduled(fixedRate=5000)
    private void configureTasks() throws InterruptedException {
        System.err.println("执行静态定时任务时间: " + LocalDateTime.now());
        asyncService.demo();
    }
}
